<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>vue样式绑定</title>
  <script src="../static/vue.js"></script>
  <style>
    .activated{
      color: red;
    }
  </style>
</head>
<body>
<div id="app">
  <div @click="handleDivClick"
       :class="[activated]"
  > 李杰
  </div>
  <!--
  class 对象绑定
  <div @click="handleDivClick"
       :class="{activated:isActivated}"
  > 李杰
  </div>-->

</div>

<script>
  var vm = new Vue({
    el: '#app',
    data: {
      activated:'',
      isActivated: false
    },
    methods: {
      handleDivClick: function () {
        // this.isActivated = !this.isActivated;
        this.activated=this.activated==='activated'?'':'activated';
      }
    }
  })
</script>
</body>
</html>
